; This conversion is important for AIML pattern matching
; because many of the rule patterns are written in the substituted
; form, e.g. "she is *". If the input is "she's beautiful" and no
; substitution is done, the rule won't be selected.

(define-public (do-aiml-subs SENT)
	(define (subs WORD)
		(define ws (cog-name WORD))
		(define (s2w . STR) (map Word STR))
		(cond
			((equal? ws "wanna") (s2w "want" "to"))
			((equal? ws "gonna") (s2w "going" "to"))
			((string-ci=? ws "I'm") (s2w "I" "am"))
			((string-ci=? ws "I'd") (s2w "I" "would"))
			((string-ci=? ws "I'll") (s2w "I" "will"))
			((string-ci=? ws "I've") (s2w "I" "have"))
			((equal? ws "you'd") (s2w "you" "would"))
			((equal? ws "you're") (s2w "you" "are"))
			((equal? ws "you've") (s2w "you" "have"))
			((equal? ws "you'll") (s2w "you" "will"))
			((equal? ws "he's") (s2w "he" "is"))
			((equal? ws "he'd") (s2w "he" "would"))
			((equal? ws "he'll") (s2w "he" "will"))
			((equal? ws "she's") (s2w "she" "is"))
			((equal? ws "she'd") (s2w "she" "would"))
			((equal? ws "she'll") (s2w "she" "will"))
			((equal? ws "we're") (s2w "we" "are"))
			((equal? ws "we'd") (s2w "we" "would"))
			((equal? ws "we'll") (s2w "we" "will"))
			((equal? ws "we've") (s2w "we" "have"))
			((equal? ws "they're") (s2w "they" "are"))
			((equal? ws "they'd") (s2w "they" "would"))
			((equal? ws "they'll") (s2w "they" "will"))
			((equal? ws "they've") (s2w "they" "have"))
			((equal? ws "y'all") (s2w "you" "all"))
			((equal? ws "can't") (s2w "can" "not"))
			((equal? ws "cannot") (s2w "can" "not"))
			((equal? ws "couldn't") (s2w "could" "not"))
			((equal? ws "wouldn't") (s2w "would" "not"))
			((equal? ws "shouldn't") (s2w "should" "not"))
			((equal? ws "isn't") (s2w "is" "not"))
			((equal? ws "ain't") (s2w "is" "not"))
			((equal? ws "don't") (s2w "do" "not"))
			((equal? ws "aren't") (s2w "are" "not"))
			((equal? ws "won't") (s2w "will" "not"))
			((equal? ws "weren't") (s2w "were" "not"))
			((equal? ws "wasn't") (s2w "was" "not"))
			((equal? ws "didn't") (s2w "did" "not"))
			((equal? ws "hasn't") (s2w "has" "not"))
			((equal? ws "hadn't") (s2w "had" "not"))
			((equal? ws "haven't") (s2w "have" "not"))
			((equal? ws "where's") (s2w "where" "is"))
			((equal? ws "where'd") (s2w "where" "did"))
			((equal? ws "where'll") (s2w "where" "will"))
			((equal? ws "who's") (s2w "who" "is"))
			((equal? ws "who'd") (s2w "who" "did"))
			((equal? ws "who'll") (s2w "who" "will"))
			((equal? ws "what's") (s2w "what" "is"))
			((equal? ws "what'd") (s2w "what" "did"))
			((equal? ws "what'll") (s2w "what" "will"))
			((equal? ws "when's") (s2w "when" "is"))
			((equal? ws "when'd") (s2w "when" "did"))
			((equal? ws "when'll") (s2w "when" "will"))
			((equal? ws "why's") (s2w "why" "is"))
			((equal? ws "why'd") (s2w "why" "did"))
			((equal? ws "why'll") (s2w "why" "will"))
			((equal? ws "it's") (s2w "it" "is"))
			((equal? ws "it'd") (s2w "it" "would"))
			((equal? ws "it'll") (s2w "it" "will"))

			((equal? ws "'m") (s2w "am"))
			((equal? ws "'d") (s2w "would"))
			((equal? ws "'ll") (s2w "will"))
			((equal? ws "'ve") (s2w "have"))
			((equal? ws "'re") (s2w "are"))
			((equal? ws "'s") (s2w "is"))

			(else (s2w ws))
		)
	)
	(List (map subs (cog-outgoing-set SENT)))
)
